package com.lgx.mobile.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.lgx.common.entity.IdGenerator;
import com.lgx.right.entity.User;

/**
 * @author xuyichen
 * 
 * 话题
 *
 */
@Entity
@Table(name = "TM_M_TOPIC")
public class Topic implements Serializable {
	
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TM_M_TOPIC_ID)
	@TableGenerator(
			name = IdGenerator.TM_M_TOPIC_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TM_M_TOPIC_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	/**
	 * 话题名称
	 */
	private String name;
	
	/**
	 * 主题
	 */
	private String topic;
	
	/**
	 * 创建者ID
	 */
	@Column(name = "create_user_id")
	private long createUserId;
	
	/**
	 * 创建时间
	 */
	@Column(name = "create_date")
	private Date createDate;
	
	/**
	 * 话题分类ID
	 */
	@Column(name = "category_id")
	private long categoryId;
	
	/**
	 * 话题图片
	 */
	private String topicImage;
	
	/**
	 * 圈子成员
	 */
	@ManyToMany(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER)    
    @JoinTable(name="TM_M_TOPIC_USER",   
             joinColumns=@JoinColumn(name="TOPIC_ID"),   
             inverseJoinColumns=@JoinColumn(name="USER_ID"))
	private Set<User> users;
	
//	/**
//	 * 圈子成员
//	 */
//	@ManyToMany(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER)    
//    @JoinTable(name="TM_M_TOPIC_USER",   
//             joinColumns=@JoinColumn(name="TOPIC_ID"),   
//             inverseJoinColumns=@JoinColumn(name="USER_ID"))
//	private Set<User> users;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTopic() {
		return topic;
	}

	public void setTopic(String topic) {
		this.topic = topic;
	}

	public long getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(long createUserId) {
		this.createUserId = createUserId;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(long categoryId) {
		this.categoryId = categoryId;
	}

	public String getTopicImage() {
		return topicImage;
	}

	public void setTopicImage(String topicImage) {
		this.topicImage = topicImage;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}
}
